package book;

public class Book {
    // 做项目的时候，成员变量几乎都是private修饰的，确保数据的安全性
    private String name;// 书名
    private String author;// 作者
    private int price;// 价格
    private String type;// 类型
    private boolean isBorrowed;// 是否被借出

    public Book(String name, String author, int price, String type/*Boolean isBorrowed*/) {// 构造方法
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
//        this.isBorrowed = isBorrowed; 这个没必要写，因为布尔类型的属性，默认值为false，意为没有被借出
    }
// 由于成员变量都是private修饰的，所以要提供公开的输入输出接口
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Boolean getBorrowed() {
        return isBorrowed;
    }

    public void setBorrowed(Boolean borrowed) {
        isBorrowed = borrowed;
    }
// 再来重写 toString 方法，让它按照我们想要额方式来输出
    @Override
    public String toString() {
        return "Book{" +
                "name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", price=" + price +
                ", type='" + type + '\'' +
                ( (isBorrowed == true)?"  已借出":"  未借出" )+
                '}';
    }
}
